import { Controller, Get, Param, Query } from '@nestjs/common';
import { ServiceService } from './service.service';
import { Service } from './entities/service.entity';
import { FindServiceDto } from './dto/find-service.dto';
import { FindServiceOptionsDto } from './dto/find-service.options.dto';

@Controller('service')
export class ServiceController {
  constructor(private readonly serviceService: ServiceService) {}

  // 查询所有的使用服务
  @Get()
  async findAndCount(@Query() query: FindServiceDto) {
    return await this.serviceService.findAndCount(query);
  }

  // 账号状态条件查询
  @Get('accountStatus/:accountStatus')
  async findByAccountStatus(
    @Param('accountStatus') accountStatus: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findByAccountStatus(accountStatus, query);
  }

  // 负责销售查询
  @Get('sell/:sellId')
  async findBySellId(
    @Param('sellId') sellId: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findBySellId(sellId, query);
  }

  // 日均流量 筛选
  @Get('flowDayAverage/:flowDayAverage')
  async findByFlowDayAverage(
    @Param('flowDayAverage') flowDayAverage: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findByFlowDayAverage(
      flowDayAverage,
      query,
    );
  }

  // 已用存储 筛选
  @Get('storageTotal/:storageTotal')
  async findByStorageTotal(
    @Param('storageTotal') storageTotal: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findByStorageTotal(storageTotal, query);
  }

  // 代金券余额 筛选
  @Get('couponRemain/:couponRemain')
  async findByCouponRemain(
    @Param('couponRemain') couponRemain: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findByCouponRemain(couponRemain, query);
  }

  // 账号搜索
  @Get('name/:accountName')
  async findByAccountName(
    @Param('accountName') accountName: Service,
    @Query() query: FindServiceDto,
  ) {
    return await this.serviceService.findByAccountName(accountName, query);
  }

  // 负责日期筛选
  @Get('time')
  async findByTime(@Query() query: FindServiceOptionsDto) {
    return await this.serviceService.findByTime(query);
  }
}
